import { createRouter, createWebHistory, type RouteRecordRaw } from 'vue-router'
import HomePage from '../views/HomePage.vue'
import Transactions from '../views/Transactions.vue'
import Billing from '../views/Billing.vue'
import Settings from '../views/Settings.vue'
import ReportsIncome from '../views/reports/IncomeReport.vue'
import ReportsCustomers from '../views/reports/CustomerReport.vue'
import ReportsTransactions from '../views/reports/TransactionReport.vue'

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    name: 'home',
    component: HomePage,
    meta: { title: '控制台' }
  },
  {
    path: '/transactions',
    name: 'transactions',
    component: Transactions,
    meta: { title: '交易记录' }
  },
  {
    path: '/billing',
    name: 'billing',
    component: Billing,
    meta: { title: '账单管理' }
  },
  {
    path: '/settings',
    name: 'settings',
    component: Settings,
    meta: { title: '系统设置' }
  },
  {
    path: '/reports/income',
    name: 'reports-income',
    component: ReportsIncome,
    meta: { title: '收入报表' }
  },
  {
    path: '/reports/customers',
    name: 'reports-customers',
    component: ReportsCustomers,
    meta: { title: '客户分析' }
  },
  {
    path: '/reports/transactions',
    name: 'reports-transactions',
    component: ReportsTransactions,
    meta: { title: '交易分析' }
  }
]

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes
})

router.beforeEach((to, from, next) => {
  document.title = `${to.meta.title} | PaySaaS`
  next()
})

export default router